#ifndef FUNDDBSPIDER_H
#define FUNDDBSPIDER_H

#include <QObject>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QNetworkAccessManager>

typedef struct {
    int timestamp;
    float rate;
    float valuation;
} valuationData_t;

typedef struct {
    int timestamp;
    float acnet;
}ACNetData_t;

class FundDBSpider : public QObject
{
    Q_OBJECT
public:
    explicit FundDBSpider(QObject *parent = nullptr);
    ~FundDBSpider();

    void ask(QString code);
    QString getString();
    QList<valuationData_t> getList();
    int getTimestamp();

private:
    QString valuationString;
    QList<valuationData_t> valuationList;
    int valuationTimestamp;
    QNetworkAccessManager* accessManger;
    void clear();
    void analyze(QString str);

signals:
    void finished(bool);

private slots:
    void requestFinished(QNetworkReply* reply);
};

#endif // FUNDDBSPIDER_H
